var pageSize = 8;
var pageIndex = 0;
$(function () {

    $('.main_t_meau li.li_o,.main_t_meau li.li_s').css('width', ($(window).width() - 482) / 2 + 'px')


    $('.banner_o_o h4').click(function () {
        $('.banner-alt,.main-bg').fadeIn();
    })
    $('.main-bg,.banner-alt a.a-o').click(function () {
        $('.banner-alt,.main-bg').hide();
    })

    ////切换
    $('.main_t_meau li').click(function () {
        var linum = $(this).index()
        $(this).addClass('on').siblings('li').removeClass('on')
        $('.main_t_m_m').eq(linum).show().siblings('.main_t_m_m').hide();

        if (linum == 0) {
            $("#type").val("pc")
            getTemple("2");

        } else if (linum == 1) {
            $("#type").val("all")
            getTemple("2");
        } else if (linum == 2) {
            $("#type").val("mbl");
            getTemple("2");
        }
        $("#carty_closr").val("");

    });


    ///  颜色切换



    $(".tem_col a").click(function () {

        $("#carty_closr").val($(this).attr("lang"));
        var type = $("#type").val();
        if (type == "pc") {
            getTemple("1");
        } else if (type == "all") {
            getTemple("2");
        } else if (type == "mbl") {
            getTemple("1");
        }


    });

    ///初始化加载模板
    getTemple("2");
});

function getTemple(teme_if) {

    var type = $("#type").val();


    var carty_closr = $("#carty_closr").val();
    $.ajax({
        type: "POST",
        dataType: "text",
        url: '/website/ajax/GetTemple.ashx',      //提交到一般处理程序请求数据  
        data: "pageIndex=" + (pageIndex + 1) + "&pageSize=" + pageSize + "&ezsite_prd=&model=" + type + "&teme_if=" + teme_if + "&type_code=3&carty_closr=" + carty_closr + "",          //提交两个参数：pageIndex(页面索引)，pageSize(显示条数)                  
        success: function (data) {

            if (type == "pc") {
                $(".main_t_m_pc").show();
                $(".main_t_m_pcwp").hide();
                $(".main_t_m_wap").hide();
                $("#main_t_m_pc").html(data+"<div class=\"clear\"></div>");
            } else if (type == "all") {
                $(".main_t_m_pc").hide();
                $(".main_t_m_pcwp").show();
                $(".main_t_m_wap").hide();
                $("#main_t_m_pcwp").html(data+"<div class=\"clear\"></div>");
            } else {

                $(".main_t_m_pc").hide();
                $(".main_t_m_pcwp").hide();
                $(".main_t_m_wap").show();
                $("#main_t_m_wap").html(data+"<div class=\"clear\"></div>");
            
            }
            $('.wap_o').hover(function () {
                $(this).find('.wap_o_zz').fadeIn(200)
            }, function () {
                $(this).find('.wap_o_zz').fadeOut(200)
            }
)

        }
    });
}
